Skip to main content

JointDef Class

Description:

  A record for creating JointDef objects.

distance

Type: Function.

Description:

  Creates a distance joint definition.

Signature:

distance: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
anchorA: Vec2,
anchorB: Vec2,
frequency?: number --[[0.0]],
damping?: number --[[0.0]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the physics body connected to joint will collide with each other.
bodyAstringThe name of first physics body to connect with the joint.
bodyBstringThe name of second physics body to connect with the joint.
anchorAVec2The position of the joint on the first physics body.
anchorBVec2The position of the joint on the second physics body.
frequencynumberThe frequency of the joint, in Hertz (default is 0.0).
dampingnumberThe damping ratio of the joint (default is 0.0).

Returns:

Return TypeDescription
JointDefThe new joint definition.

friction

Type: Function.

Description:

  Creates a friction joint definition.

Signature:

friction: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
maxForce: number,
maxTorque: number): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the physics body connected to joint will collide with each other.
bodyABodyThe name of first physics body to connect with the joint.
bodyBBodyThe name of second physics body to connect with the joint.
worldPosVec2The position of the joint in the game world.
maxForcenumberThe maximum force that can be applied to the joint.
maxTorquenumberThe maximum torque that can be applied to the joint.

Returns:

Return TypeDescription
JointThe new friction joint definition.

gear

Type: Function.

Description:

  Creates a gear joint definition.

Signature:

gear: function(self: JointDefClass,
canCollide: boolean,
jointA: string,
jointB: string,
ratio?: number --[[1.0]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the physics bodies connected to the joint can collide with each other.
jointAJointThe name of first joint to connect with the gear joint.
jointBJointThe name of second joint to connect with the gear joint.
rationumberThe gear ratio (default is 1.0).

Returns:

Return TypeDescription
JointThe new gear joint definition.

spring

Type: Function.

Description:

  Creates a new spring joint definition.

Signature:

spring: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
linearOffset: Vec2,
angularOffset: number,
maxForce: number,
maxTorque: number,
correctionFactor?: number --[[1.0]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether the connected bodies should collide with each other.
bodyABodyThe name of first body connected to the joint.
bodyBBodyThe name of second body connected to the joint.
linearOffsetVec2Position of body-B minus the position of body-A, in body-A's frame.
angularOffsetnumberAngle of body-B minus angle of body-A.
maxForcenumberThe maximum force the joint can exert.
maxTorquenumberThe maximum torque the joint can exert.
correctionFactornumberOptional correction factor, defaults to 1.0.

Returns:

Return TypeDescription
JointThe created joint definition.

prismatic

Type: Function.

Description:

  Creates a new prismatic joint definition.

Signature:

prismatic: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
axisAngle: number,
lowerTranslation?: number --[[0.0]],
upperTranslation?: number --[[0.0]],
maxMotorForce?: number --[[0.0]],
motorSpeed?: number --[[0.0]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether the connected bodies should collide with each other.
bodyABodyThe name of first body connected to the joint.
bodyBBodyThe name of second body connected to the joint.
worldPosVec2The world position of the joint.
axisAnglenumberThe axis angle of the joint.
lowerTranslationnumberOptional lower translation limit, defaults to 0.0.
upperTranslationnumberOptional upper translation limit, defaults to 0.0.
maxMotorForcenumberOptional maximum motor force, defaults to 0.0.
motorSpeednumberOptional motor speed, defaults to 0.0.

Returns:

Return TypeDescription
MotorJointThe created prismatic joint definition.

pulley

Type: Function.

Description:

  Create a pulley joint definition.

Signature:

pulley: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
anchorA: Vec2,
anchorB: Vec2,
groundAnchorA: Vec2,
groundAnchorB: Vec2,
ratio?: number --[[1.0]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the connected bodies will collide with each other.
bodyABodyThe name of first physics body to connect.
bodyBBodyThe name of second physics body to connect.
anchorAVec2The position of the anchor point on the first body.
anchorBVec2The position of the anchor point on the second body.
groundAnchorAVec2The position of the ground anchor point on the first body in world coordinates.
groundAnchorBVec2The position of the ground anchor point on the second body in world coordinates.
rationumber[optinal] The pulley ratio (default 1.0).

Returns:

Return TypeDescription
JointThe pulley joint definition.

revolute

Type: Function.

Description:

  Create a revolute joint definition.

Signature:

revolute: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
lowerAngle?: number --[[0.0]],
upperAngle?: number --[[0.0]],
maxMotorTorque?: number --[[0.0]],
motorSpeed?: number --[[0.0]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the connected bodies will collide with each other.
bodyABodyThe name of first physics body to connect.
bodyBBodyThe name of second physics body to connect.
worldPosVec2The position in world coordinates where the joint will be created.
lowerAnglenumber[optinal] The lower angle limit (radians) (default 0.0).
upperAnglenumber[optinal] The upper angle limit (radians) (default 0.0).
maxMotorTorquenumber[optinal] The maximum torque that can be applied to the joint to achieve the target speed (default 0.0).
motorSpeednumber[optinal] The desired speed of the joint (default 0.0).

Returns:

Return TypeDescription
MotorJointThe revolute joint definition.

rope

Type: Function.

Description:

  Create a rope joint definition.

Signature:

rope: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
anchorA: Vec2,
anchorB: Vec2,
maxLength: number): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the connected bodies will collide with each other.
bodyABodyThe name of first physics body to connect.
bodyBBodyThe name of second physics body to connect.
anchorAVec2The position of the anchor point on the first body.
anchorBVec2The position of the anchor point on the second body.
maxLengthnumber[optinal] The maximum distance between the anchor points (default 0.0).

Returns:

Return TypeDescription
JointThe rope joint definition.

weld

Type: Function.

Description:

  Creates a weld joint definition.

Signature:

weld: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
frequency?: number --[[0.0]],
damping?: number --[[0.0]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the bodies connected to the joint can collide with each other.
bodyABodyThe name of first body to be connected by the joint.
bodyBBodyThe name of second body to be connected by the joint.
worldPosVec2The position in the world to connect the bodies together.
frequencynumber[optional] The frequency at which the joint should be stiff, defaults to 0.0.
dampingnumber[optional] The damping rate of the joint, defaults to 0.0.

Returns:

Return TypeDescription
JointThe newly created weld joint definition.

wheel

Type: Function.

Description:

  Creates a wheel joint definition.

Signature:

wheel: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
axisAngle: number,
maxMotorTorque?: number --[[0.0]],
motorSpeed?: number --[[0.0]],
frequency?: number --[[2.0]],
damping?: number --[[0.7]]): JointDef

Parameters:

ParameterTypeDescription
canCollidebooleanWhether or not the bodies connected to the joint can collide with each other.
bodyABodyThe name of first body to be connected by the joint.
bodyBBodyThe name of second body to be connected by the joint.
worldPosVec2The position in the world to connect the bodies together.
axisAnglenumberThe angle of the joint axis in radians.
maxMotorTorquenumber[optional] The maximum torque the joint motor can exert, defaults to 0.0.
motorSpeednumber[optional] The target speed of the joint motor, defaults to 0.0.
frequencynumber[optional] The frequency at which the joint should be stiff, defaults to 2.0.
dampingnumber[optional] The damping rate of the joint, defaults to 0.7.

Returns:

Return TypeDescription
MotorJointThe newly created wheel joint definition.